package com.etc.controller;

import com.etc.dto.Result;
import com.etc.service.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/history")
public class HistoryController {

    @Autowired
    private HistoryService historyService;

    @GetMapping("/delete")
    public @ResponseBody Result deleteDetail(@RequestParam String historyId){
        boolean falg = historyService.deleteHistoryDetail(historyId);
        if(falg){
            return new Result().ok(true);
        }else {
            return new Result().fail(0,"删除失败");
        }
    }
    @GetMapping("/add")
    public @ResponseBody Result addDetail(@RequestParam String patientName,@RequestParam String doctorId,@RequestParam String content){
        boolean falg = historyService.insertHistoryDetail(patientName, doctorId, content);
        if(falg){
            return new Result().ok(true);
        }else {
            return new Result().fail(0,"添加失败");
        }
    }
    @GetMapping("/update")
    public @ResponseBody Result updateDetail(@RequestParam String historyId,@RequestParam String historyContent){
        boolean falg = historyService.updateHistoryDetail(historyId, historyContent);
        if(falg){
            return new Result().ok(true);
        }else {
            return new Result().fail(0,"修改失败");
        }
    }
}
